/**
*   FuzzyEngine - an Simple flex framework 
*   Copyright (C) 2010 Constantin Aldea
*
*   This program is free software: you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation, either version 3 of the License, or
*   (at your option) any later version.
*   This program is distributed in the hope that it will be useful,
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*   GNU General Public License for more details.
*
*   You should have received a copy of the GNU General Public License
*   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package project.controller {
	import fuzzy.penelope.controller.GenericController;
	import fuzzy.penelope.model.vo.framework.access.Persona;

	import mx.rpc.AsyncToken;

	import flash.events.Event;

	public class TestModuleController extends GenericController
	{
		
		public function nuovoDocumento(input:Object):AsyncToken{
			return this.createDocument(input);
		}
		
		public function commit(input:Object):AsyncToken{
			if(input.id == null){
				return this.createDocument(input);
			}else{
				return this.modifyDocument(input);
			}
		}
		
		public function caricaDocumento(id:String):AsyncToken
		{
			return service.localRestCall("person.xml", id, genericListener); 
		}
		
		public function loadDocument(id:String):AsyncToken{
			if(context.debug == true){
				return service.localRestCall("caricaGrafo.xml", null, genericListener );
			}else			
				return service.restCall(Persona, id); 
		}
		
		
		public function modifyDocument( input:Object ):AsyncToken
		{
			 return service.restCall(Persona, Persona.MODULE_NAME, "1", input);
		}
		
		public function createDocument( input:Object ):AsyncToken
		{
			 return service.restCall(Persona, Persona.MODULE_NAME, "1", input); 
		}
	
		public function eliminaDocumento(id:String):AsyncToken{
			 return service.restCall(Persona, id); 
		}
		

		public function elencoFunzioniDisponibili(id:String):AsyncToken{
			 return service.restCall(Persona, id); 
		}
		
		private function genericListener(e:Event):void{
			trace("oke");
		}
		
	}
}